package com.xinghai.common.utils;

/**
 * 校验工具类
 */
public class VerifyUtil {

    //手机号规则
    public static String PHONE_RULE = "(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}";
    //邮箱校验
    public static String EMAIL_RULE = "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$";


    /***
     * 手机号校验
     * @param phone
     * @return
     */
    public static boolean phoneNumber(String phone){
        if (StringUtils.isEmpty(phone)){
            return false;
        }
        return phone.matches(PHONE_RULE);
    }
    /***
     * 邮箱校验
     * @param email
     * @return
     */
    public static boolean email(String email){
        if (StringUtils.isEmpty(email)){
            return false;
        }
        return email.matches(EMAIL_RULE);
    }
}
